from lib.config import *
from lib.feature_extractor_v2 import MFCCExtractor, FbankExtractor
from lib.file_processor import FileProcessor
from lib.file_utils import clear_folder

# # mfcc特征提取
# mfcc_extractor = MFCCExtractor()
#
#
# def process_mfcc(file_path, identity_id):
#     return mfcc_extractor.extract_features(file_path)
#
#
# mfcc_output_root = os.path.join(featureRoot, 'mfcc')
# os.makedirs(mfcc_output_root, exist_ok=True)
# clear_folder(mfcc_output_root)
# file_processor = FileProcessor(originDatasetAddr, process_mfcc,
#                                output=True,
#                                output_fmt='npy-list',
#                                output_root=mfcc_output_root)
# file_processor.process_files()

# fbank特征提取
fbank_extractor = FbankExtractor()


def process_fbank(file_path, identity_id):
    return fbank_extractor.extract_features(file_path, identity_id)


fbank_output_root = os.path.join(featureRoot, 'fbank')
os.makedirs(fbank_output_root, exist_ok=True)
clear_folder(fbank_output_root)
file_processor = FileProcessor(originDatasetAddr, process_fbank,
                               output=True,
                               output_fmt='npy-list',
                               output_root=fbank_output_root)
file_processor.process_files()
